#include <stdio.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>

#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/types.h>

int main(int argc, char const *argv[])
{
    FILE *fp = fopen("config","r");
    if(fp == NULL)
    {
        printf("open config failed\n");
        return 0;
    }
    
    char lib[50];
    fgets(lib,50,fp);
    fclose(fp);

    // 打开动态库
    void *handle = dlopen(lib,RTLD_NOW);
    if(handle == NULL)
    {
        printf("dlopen failed\n");
        return 0;
    }

    // 定义函数指针
    void(*f)(void);
    f = dlsym(handle,"detection");
    if(f == NULL)
    {
        printf("dlsym failed\n");
        return 0;
    }

    f();

    dlclose(handle);

    return 0;
}

